import java.util.Arrays;

public class Test4 {
    //给定一个整型数组, 实现冒泡排序(升序排序)

    public static void paoSort(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            boolean flag = false;
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                } else {
                    flag = true;
                }
            }
            if (flag == true) {
                return;
            }
        }
    }
    public static void main(String[] args) {
        int[] arr = new int[]{6,5,4,3,2,1};

        System.out.println(Arrays.toString(arr));

        paoSort(arr);

        System.out.println(Arrays.toString(arr));
    }
}
